package boot

import (
	"fmt"

	"gitee.com/johng/gf/g"
	//"gitee.com/johng/gf/g/database/gdb"
	"gitee.com/johng/gf/g/os/gfile"
	_ "github.com/mattn/go-sqlite3"
)

var (
	DBS = map[string]string{
		"qiyedb": `CREATE TABLE qiyedb(
  	id INTEGER  PRIMARY KEY  AUTOINCREMENT,
    qiyename TEXT,
	diqu TEXT,
	dizhi TEXT,
    guimo TEXT,
    biaoqian TEXT,
    zhushengchan TEXT,
    zonghexinzi TEXT,
    faxinri TEXT,
	xinzijiegou TEXT,
	huoshi TEXT,
	zhusu TEXT,
	changche TEXT,
	gangwei TEXT,
	zhuozhuang TEXT,
	zhanzuo TEXT,
	banbie TEXT,
	qita TEXT,
	shifouzhaopin TEXT,
	shenfenzheng TEXT,
	xueli TEXT,
	wenshen TEXT,
	yanba TEXT,
	fanchangguiding TEXT,
	tijian TEXT,
	sfzfyj TEXT,
	byzfyj TEXT,
	zhaopian TEXT,
	gongzhong TEXT,
	xingbie TEXT,
	nianling TEXT,
	gongjia TEXT,
	fanfeitianshu TEXT,
	zongfanfei TEXT,
	huiyuanfanfei TEXT,
	jingjirenticheng TEXT,
	beizhu TEXT,
	riqi TEXT,
	laowu TEXT
);`,
	}
)

func Initdatas() {

	if gfile.Exists("data/main.db") {
		return
	} else {
		if gfile.Exists("data") {
			gfile.Mkdir("data")
		}
		gfile.Create("data/main.db")
		db := g.Database()

		_, err := db.Exec(DBS["qiyedb"])
		if err != nil {
			fmt.Println("创建数据库时出错！", err)
			return
		}

	}

}
